package org.penguin.study.bk.user.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.penguin.study.bk.base.annotation.Dict;
import org.penguin.study.bk.base.api.UUIDEntity;
import org.penguin.study.bk.enums.Gender;
import org.penguin.study.bk.organization.entity.Organization;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDate;

/**
 * @author chengyinghua
 */
@Data
@Entity
@Table(name = "tbl_users")
@TableName("tbl_users")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(title = "tbl_users表对象", description = "用户信息")
public class User extends UUIDEntity implements Serializable {

    private static final long serialVersionUID = -1800493339215815530L;

    @Id
    @TableId
    @GeneratedValue(generator = "jpa-uuid")
    private String id;

    @NotBlank(message = "Please enter the FullName")
    private String fullName;

    @Column(length = 20, nullable = false, unique = true)
    @NotBlank(message = "Account is mandatory")
    private String account;

    @Column(length = 60, nullable = false, name = "password_")
    @TableField("password_")
    private String password;

    @Column(length = 40, nullable = false)
    @NotBlank(message = "NickName is mandatory")
    private String nickName;

    private Gender gender;

    private String email;

    private byte[] logo;

    private Organization organization;

    private LocalDate birthday;

    private String description;

    @Dict(dicCode = "dict_user_status")
    private String status;

}
